<?php
include './Classes/PHPExcel/IOFactory.php';
date_default_timezone_set('PRC');
echo '<pre>';

error_reporting(E_ALL);
       
$objPHPExcel = new PHPExcel();

$data = unserialize(file_get_contents('shcar.txt'));

// print_r($data);
// exit;
// $data = ['0'=>['ss'=>'哈哈']];
$name = '测试';
/*以下是一些设置 ，什么作者  标题啊之类的*/
$objPHPExcel->getProperties()->setCreator("heal")
->setLastModifiedBy("heal")
->setTitle("数据EXCEL导出")
->setSubject("数据EXCEL导出")
->setDescription("备份数据")
->setKeywords("excel")
->setCategory("result file");
/*以下就是对处理Excel里的数据， 横着取数据，主要是这一步，其他基本都不要改*/
$num = 0;
foreach($data as $k => $v){
        $num++;
        $objPHPExcel->setActiveSheetIndex(0)//Excel的第A列，uid是你查出数组的键值，下面以此类推
                    ->setCellValue('A'.$num, $v['aplc_car_no'])
                    ->setCellValue('B'.$num, $v['aplc_car_vin'])
                    ->setCellValue('C'.$num, $v['realname'])
                    ->setCellValue('D'.$num, $v['cxhname'])
                    ->setCellValue('E'.$num, $v['mobile'])
                //     ->setCellValue('F'.$num, $v['newmobile'])
                //     ->setCellValue('F'.$num, $v['newcxhname'])
                    ;   
                     
}
 
$objPHPExcel->getActiveSheet()->setTitle('User');
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: applicationnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$name.'.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;

?>